package android.slc.extras.system.domain

import android.slc.appbase.config.ConstantsBase
import android.slc.appbase.ui.vd.BaseAppVmBox
import android.slc.core.vm.SingleLiveEvent
import com.kunminx.architecture.ui.callback.ProtectedUnPeekLiveData
import com.kunminx.architecture.ui.callback.UnPeekLiveData

class StartupPermissionsVmBox: BaseAppVmBox() {

    val requestPermissions = SingleLiveEvent<Array<String>>()

    private var normalRequestPermission = false

    private val allPermissionsGrantedVd = UnPeekLiveData<Boolean>()

    fun allPermissionsGrantedVd(): ProtectedUnPeekLiveData<Boolean> {
        return allPermissionsGrantedVd
    }

    fun isAllPermissionsGranted():Boolean{
        return allPermissionsGrantedVd.value==true
    }

    fun setAllPermissionsGranted(){
        allPermissionsGrantedVd.value = true
    }

    /**
     * 监察权限
     */
    fun checkPermission() {
        if (!normalRequestPermission) {
            normalRequestPermission = true
            requestPermissions.value = ConstantsBase.Permission.getBasePermissionArray()
        }
    }

    fun resetNormalRequestPermissionStatus() {
        normalRequestPermission = false
    }

}